package com.project.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.project.bean.SellBean;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

import java.time.LocalDate;

@Mapper
public interface ISellMapper extends BaseMapper<SellBean> {
    IPage<SellBean> findByItem(@Param("pageNO") Page pageNo,
                               @Param("name") String clientName,
                               @Param("startDate") LocalDate startDate,
                               @Param("endDate") LocalDate endDate);

    @Insert("SELECT tc.*,tc.c_name,ti.*,tp.* FROM t_sell ts,t_client tc," +
            "t_sellInfo ti,t_product tp WHERE ts.`fk_clientId` = tc.`pk_clientId` " +
            "AND ts.`pk_sellId` = ti.`fk_sellId` AND ti.`fk_productId` = tp.`pk_productId` " +
            "AND ts.`pk_sellId` = #{id}")
    SellBean findById(Integer id);

}
